package com.sai.jsai.module.system.service.impl;

import com.sai.jsai.common.starter.mybatisplus.service.impl.BaseServiceImpl;
import com.sai.jsai.module.system.dal.entity.SysUserRole;
import com.sai.jsai.module.system.dal.mapper.SysUserRoleMapper;
import com.sai.jsai.module.system.service.SysUserRoleService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author jisai
 * @version 0.0.1
 * @Description 系统用户角色关联表 服务实现类
 * @createTime 2024/09/24
 */
@Service
public class SysUserRoleServiceImpl extends BaseServiceImpl<SysUserRoleMapper, SysUserRole> implements SysUserRoleService {

    /**
     * 根据用户ID获取角色ID列表
     *
     * @param sysUserId 用户ID
     * @return 角色ID列表
     */
    @Override
    public List<Long> getRoleIdsByUserId(Long sysUserId) {
        List<SysUserRole> sysUserRoles = this.baseMapper.selectListByUserId(sysUserId);
        return sysUserRoles.stream().map(SysUserRole::getRoleId).toList();
    }

}
